<template>
  <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="450px" :title="`${drawerProps.title}`">
    <el-space direction="vertical">
      <el-descriptions :column="1" title="缴款单信息" border>
        <el-descriptions-item width="300" label="客户姓名">{{ drawerProps.row.customInfo?.customerName }}</el-descriptions-item>
        <el-descriptions-item width="300" label="客户电话">{{ drawerProps.row?.customInfo?.customerPhone }}</el-descriptions-item>
        <el-descriptions-item width="300" label="缴款单类型">
          <el-tag v-if="drawerProps.row?.paymentType === 0" type="success">收款</el-tag>
          <el-tag v-if="drawerProps.row?.paymentType === 1" type="danger">退款</el-tag>
        </el-descriptions-item>
        <el-descriptions-item width="300" label="配送员姓名">{{ drawerProps.row.courierInfo?.courierName }}</el-descriptions-item>
        <el-descriptions-item width="300" label="支付总额">{{ drawerProps.row?.paymentTotal }}</el-descriptions-item>
        <el-descriptions-item width="300" label="创建时间">{{ drawerProps.row?.createTime }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions :column="1" title="订单项信息" border>
        <el-descriptions-item width="300" label="商品名称">{{ drawerProps.row.orderItems?.[0]?.goodsName }}</el-descriptions-item>
        <el-descriptions-item width="300" label="商品价格">{{
          drawerProps.row.orderItems?.[0]?.goodsPrice
        }}</el-descriptions-item>
        <el-descriptions-item width="300" label="商品数量">{{ drawerProps.row.orderItems?.[0]?.count }}</el-descriptions-item>
        <el-descriptions-item width="300" label="计量单位">{{
          drawerProps.row.orderItems?.[0]?.measureUnit
        }}</el-descriptions-item>
      </el-descriptions>
    </el-space>
    <template #footer>
      <el-button @click="drawerVisible = false">取消</el-button>
    </template>
  </el-drawer>
</template>

<script setup lang="ts" name="DetailDrawer">
import { ref } from "vue";
import { Substation } from "@/api/interface";

interface DrawerProps {
  title: string;
  isView: boolean;
  row: Partial<Substation.ResPaymentList>;
  api?: (params: any) => Promise<any>;
  getTableList?: () => void;
}

const drawerVisible = ref(false);
const drawerProps = ref<DrawerProps>({
  isView: false,
  title: "",
  row: {}
});

// 接收父组件传过来的参数
const acceptParams = (params: DrawerProps) => {
  drawerProps.value = params;
  drawerVisible.value = true;
};

defineExpose({
  acceptParams
});
</script>
